<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Todo List</title>
    <link rel="stylesheet" href="styles.css">
    <!-- <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f4f4f4;
            margin: 0;
            padding: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
        }

        .container {
            background-color: #fff;
            padding: 20px;
            border-radius: 5px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            text-align: center;
        }

        h1 {
            margin-bottom: 20px;
        }

        input[type="text"] {
            width: 70%;
            padding: 10px;
            margin-bottom: 10px;
            border: 1px solid #ddd;
            border-radius: 5px;
        }

        button {
            padding: 10px 20px;
            background-color: #5cb85c;
            color: #fff;
            border: none;
            border-radius: 5px;
            cursor: pointer;
        }

        button:hover {
            background-color: #4cae4c;
        }

        ul {
            list-style: none;
            padding: 0;
        }

        li {
            margin-bottom: 10px;
            padding: 10px;
            background-color: #f9f9f9;
            border: 1px solid #ddd;
            border-radius: 5px;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        li button {
            background-color: #d9534f;
            color: #fff;
            border: none;
            padding: 5px 10px;
            border-radius: 5px;
            cursor: pointer;
        }

        li button:hover {
            background-color: #c9302c;
        }
    </style> -->
</head>

<body>
    <div class="container">
        <h1>Todo List</h1>
        <input type="text" id="todoInput" placeholder="Add a new task">
        <button id="addButton">Add</button>
        <ul id="todoList"></ul>
    </div>
    <script>
        document.getElementById('addButton').addEventListener('click',addTodo)
        document.getElementById('todoInput').addEventListener('keyup',function(e){
            if(e.key==='Enter'){
                addTodo()
            }
        })
        function addTodo(){
            const todoInput = document.getElementById('todoInput')
            const todoList = document.getElementById('todoList')
            const todoText = todoInput.value.trim()
            if(todoText===''){
                alert('Please enter a task')
                return
            }
            const li = document.createElement('li')
            li.innerHTML = `<span>${todoText}</span><button onclick="removeTodo(this)">Remove</button>`
            todoList.appendChild(li)
            todoInput.value=''
        }
        function removeTodo(button){
            const li = button.parentNode
            li.parentNode.removeChild(li)
        }
    </script>
</body>

</html>